<extend name="Base/common"/>
<block name="body">
<div class="container">
<div class="nav">
    <img src="__IMG__/img_1.png" alt="" id="show">          
    <h3>绑定银行卡</h3>
</div>
<div class="bank-bindbox">
<div class="bank-bindtop">
	<img src="__IMG__/icon07.png" class="bank-binding" /> &nbsp;提现卡绑定
</div>
<div class="bank-bindconter">
	<input type="text" class="bank-bindinput" name="bank_realname" id="bank_realname" placeholder="银行卡持卡人"/>
	<input type="text" class="bank-bindinput" name="bank_card" id="bank_card" placeholder="银行卡卡号"/>
	<input type="text" class="bank-bindinput" name="id_card" id="id_card" placeholder="持卡人身份证号"/>

	<div class="bank-bindselect">
		<img src="__IMG__/icon08.png"  class="bank-binddown"/>
		<div class="bank-xians">中国银行</div>
		<div class="bank-moni clearfix">
		</div>
	</div>
	<input type="text" class="bank-bindinput" id="outlets_name" name="outlets_name" placeholder="开户行地址"/>
	<input type="text" class="bank-bindinput" name="pro_name" id="pro_name" placeholder="开户省份"/>
	<input type="text" class="bank-bindinput" name="city_name" id="city_name" placeholder="开户市"/>
	<p class="bank-bindtips">为了您的资金安全，此帐号为您唯一的提现账号，请务必仔细核对以上信息</p>
	<p class="bank-bindtips clearfix">
		<a class="bank-bindok bank-bindti" href="javascript:subform()">确认</a>
		<a href="javascript:reset()" class="bank-bindno bank-bindti">取消</a>
	</p>
</div>
</div>
<script src="__JS__/bank.js" type="text/javascript" charset="utf-8"></script>
<script type="text/javascript">
$('.bank-xians').click(function(){
	$('.bank-moni').toggle();
})
for(var i=0;i<b_data.length;i++){
	$('.bank-moni').append('<div>'+b_data[i]+'</div>');
	$('.bank-moni').find('div').eq(i).click(function(){
			$('.bank-moni').find('div').removeClass('ass');
			$(this).addClass('ass');
			$('.bank-moni').toggle();
			var val=$(this).html();
			$('.bank-xians').html(val);
	})
};



function subform(){
	var bank_name=$('.bank-xians').html();
	var bank_realname=$('#bank_realname').val();
	var bank_card=$('#bank_card').val();
	var id_card=$('#id_card').val();
	var id_card_length=id_card.length;
	
	var outlets_name=$('#outlets_name').val();
	var pro_name=$('#pro_name').val();
	var city_name=$('#city_name').val();
	var url="{:U('User/bank_binding')}";
	if(bank_name==''){
		alert('银行名称不能为空');
		return false;
	}
	if(bank_realname==''){
		alert('持卡人不能为空');
		return false;
	}
	var reg = /^(\d{16}|\d{18}|\d{19})$/;
	if( !reg.test(bank_card) ) { 
		//alert("银行卡号，应该是16或19位数字！"); 
		//return false;
	}
	if (id_card.length != 15 && id_card.length != 18) { 
		alert("输入身份证号码格式不正确!"); 
		return false; 
	} 
	if(outlets_name==''){
		alert('开户行地址不能为空');
		return false;
	}
	if(pro_name==''){
		alert('开户省不能为空');
		return false;
	}
	if(city_name==''){
		alert('开户市不能为空');
		return false;
	}
	$.post(url,
			{
				bank_name:bank_name,
				bank_realname:bank_realname,
				bank_card:bank_card,
				id_card:id_card,
				outlets_name:outlets_name,
				pro_name:pro_name,
				city_name:city_name,
			},function(data){
          		if(data.status){
          			alert(data.msg);
          			//return false;
          			//$('.msg').html(data.msg);
          			setTimeout(link_url,1000);	
          		}else{
          			alert(data.msg);
          			return false;
          			//$('.msg').html(data.msg);
          		}
        },'json') 
}

function link_url(){
		var url_href="{:U('User/bank_index')}";
		window.location.href=url_href;		
}
function reset(){
	window.location.reload();
}
</script>
</div>
</block>